How to ascertain which shell is the OS-default shell?

I’ve used

chsh --shell (Get-Command 'bash').Source $([Environment]::UserName <# https://stackoverflow.com/a/58565805/9731176 #>) <# https://stackoverflow.com/a/69876130/9731176 #>

to change my shell for the sake of [Distribution Support Request] openSUSE Tumbleweed · Issue #20469 · PowerShell/PowerShell · GitHub but now want to revert it to the OS-default shell. I’m aware that this is bash, as aforedemonstrated, but instead of just using whichever is preferent in $Env:PATH, I’d like to be able to determine programmatically which is designated as the default after installation (if it’s possible).

@rokejulianlockhart env may be better…?

:~> pwsh
PS /home/user> echo $SHELL
PS /home/user> env | grep SHELL=
SHELL=/bin/bash
PS /home/user> exit             
:~> echo $SHELL
/bin/bash
:~> env | grep SHELL=
SHELL=/bin/bash
1 Like

Thanks for the pointer, @myswtest and @malcolmlewis. However, it seems like What sets the $SHELL environment variable? - Unix & Linux Stack Exchange states that the $Env:SHELL variable can and sometimes is set by things like the DE, so it’s not as reliable as what What sets the $SHELL environment variable? - Unix & Linux Stack Exchange describes:

You can check the default values of your system in /etc/default/useradd or with sudo useradd -D, this will output the default value for $SHELL and other variables.

(…which, summarily, is listing /etc/default/useradd):

PS /home/RokeJulianLockhart> sudo cat -vbET '/etc/default/useradd'
[sudo] password for root: 
     1  # useradd defaults file$
     2  GROUP=100$
     3  GROUPS=$
     4  HOME=/home$
     5  INACTIVE=-1$
     6  EXPIRE=$
     7  SHELL=/bin/bash$
     8  SKEL=/etc/skel$
     9  USRSKEL=/usr/etc/skel$
    10  CREATE_MAIL_SPOOL=yes$
    11  LOG_INIT=yes$

…specifically:

PS /home/RokeJulianLockhart> sudo cat -vbET '/etc/default/useradd' | Select-String 'SHELL='

     7  SHELL=/bin/bash$

@rokejulianlockhart:

Possibly even more definitive –

 > rpm --query --whatprovides /etc/default/useradd
shadow-4.8.1-150400.10.12.1.x86_64
 >

You’ll have to delve into OBS to see if, the SUSE team have changed the Linux default values.
Another place to check is the Linux Foundation standards –
<https://www.linuxfoundation.org/>
<https://www.linuxfoundation.org/projects/standards>
Please note that, the Linux Standard Base has been abandoned –
<https://wiki.linuxfoundation.org/lsb/start>

1 Like

@dcurtisfra, per:

  1. PS /home/RokeJulianLockhart> rpm --query --whatprovides '/etc/default/useradd'
    file /etc/default/useradd is not owned by any package
    
  2. PS /home/RokeJulianLockhart> bash
    RokeJulianLockhart@s1e8h4:~> rpm --query --whatprovides /etc/default/useradd
    file /etc/default/useradd is not owned by any package
    

…any idea why this doesn’t work for me?

For instance, interestingly, searching for the term “bash” in the Source Files search bar at Show openSUSE:Factory / shadow - openSUSE Build Service doesn’t yield any results, so maybe rpm was correct for me?

@rokejulianlockhart read the Changelog? What @dcurtisfra posted is for the Leap version…

Tue Aug 17 15:08:09 UTC 2021 ...
- Update to 4.9:
.....
Remove %{_sysconfdir}/default/useradd: file not shipped anymore
2 Likes

I’ve not much idea how to do that, @malcolmlewis. I’ve never read an RPM package’s changelog. Apologies.

@rokejulianlockhart first place to look… but if you use zypper se --provides type search and you get no result then very likely is gone… It may still be present of course on an older install…

rpm -qa --changelog | grep default/useradd
rpm -q shadow --changelog | grep default/useradd

Stupid question –

  • If, for Tumbleweed, ‘/etc/default/useradd’ is no longer provided by the “shadow” package and –
    useradd” still requires that file, how is “useradd” going to supply a new user’s defaults?

Or, has someone suggested that, a new user’s defaults shall be hard-coded into “useradd” ???

1 Like

@dcurtisfra AFAIK all of the previous patches were upstreamed and taken care of. FWIW useradd in MicroOS has no file, when installing via Combustion I create my user and it’s all in the correct location /home/user etc… Likewise Aeon installs via iso image…